package main.reports;

import main.OpenProjectDialog;
import main.Trees.ProjectNode;
import javax.swing.*;
import java.awt.*;
import java.sql.Connection;
import java.util.ArrayList;

public class SumTableDataThread {

    private ProjectNode curProject;
    private Connection connSQL;
    private Frame parent;
    private String type, sectionSelect;
    private SelectProjectDialog op;
    private ArrayList<ProjectNode> projectList;

    public SumTableDataThread(Frame parent, ArrayList<ProjectNode> projectList, Connection connSQL, String type, String sectionSelect) {
        this.projectList = projectList;
        this.connSQL = connSQL;
        this.parent = parent;
        this.type = type;
        this.sectionSelect = sectionSelect;
    }

    public void run() {
        if (type.contains("normal")) {
            XLSSetup report = new XLSSetup(projectList, connSQL, sectionSelect, type);
            report.start();
        } else if (type.contains("extend")) {
            ReportOneExtend report = new ReportOneExtend(projectList.get(0), connSQL, sectionSelect, type);
            report.start();
        }
    }

    private void centerOnScreen(Container win) {
        GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        Rectangle bounds = gd.getDefaultConfiguration().getBounds();
        Dimension winDim = win.getSize();
        Point loc = new Point((bounds.width - winDim.width) / 2, (bounds.height - winDim.height) / 2);
        win.setLocation(loc);

    }



}
